﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DataCore;
using DataCore.DomainObjects;

namespace ExpertSystem.Controls
{
    public partial class ObjectDataGridView : UserControl
    {
        private List<CurrentObject> _data;

        public ObjectDataGridView()
        {
            InitializeComponent();
        }

        public void Init(List<CurrentObject> data, MetaClass metaClass)
        {
            _data = data;
            foreach (Atribute atribute in metaClass.Atributes)
            {
                DataGridViewColumn dataGridViewColumn = new DataGridViewColumn();
                dataGridViewColumn.Name = atribute.Name;
                dataGridView1.Columns.Add(dataGridViewColumn);
            }
        }

        public void DisplayData()
        {
            foreach (CurrentObject currentObject in _data)
            {
                DataGridViewRow dataGridViewRow = new DataGridViewRow();
               
                foreach (Value value in currentObject.Values)
                {
                    DataGridViewTextBoxCell dataGridViewTextBoxCell = new DataGridViewTextBoxCell();
                    dataGridViewTextBoxCell.Value= value.GetAsString();
                    dataGridViewRow.Cells.Add(dataGridViewTextBoxCell);
                    //dataGridViewRow.Cells[i].ValueType = value.Atribute.
                }
                dataGridView1.Rows.Add(dataGridViewRow);
            }
        }

        private void ObjectDataGridView_Paint(object sender, PaintEventArgs e)
        {
          //  DisplayData();
        }


    }
}
